<?php

namespace Tbf\Bundle\JobTriggerBundle;

use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

class JobTrigger extends EventDispatcher
{
    protected $log;
    public function __construct(LoggerInterface $log)
    {
        $this->log = $log;
    }
    public function execute()
    {
        //如果发生异常需要记录在log里面
        $this->log->info('tbf.job_trigger execute');
        try {
            $this->dispatch('job_trigger',null);
        } catch (\Exception $e) {
            $this->log->error('tbf.job_trigger catch an exception',array(
               'msg' => $e->getMessage(),
               'trace'=>$e->getTraceAsString()
            ));
            throw $e;
        }
    }
}
